unit untAbsRel;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ActnList, Vcl.ImgList, Vcl.Buttons,
  Vcl.ExtCtrls,DBCtrls;

type
  TfrmAbsRel = class(TForm)
    Bevel1: TBevel;
    SpeedButton9: TSpeedButton;
    SpeedButton1: TSpeedButton;
    imgAbs24: TImageList;
    ActionList1: TActionList;
    acGeraRelatorio: TAction;
    acSair: TAction;
    procedure acSairExecute(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    procedure AtualizaLookUps; virtual;
    procedure FechaLookUps; virtual;

  public
    { Public declarations }
  end;

var
  frmAbsRel: TfrmAbsRel;

implementation

{$R *.dfm}

procedure TfrmAbsRel.acSairExecute(Sender: TObject);
begin
  Close;
end;

procedure TfrmAbsRel.AtualizaLookUps;
var
  i : Integer;
begin
  for i := 0 to Self.ComponentCount -1 do
  if (Components[i] is TDBLookupComboBox ) then
    if TDBLookupComboBox(Components[i]).Tag = 0 then
    begin
       TDBLookupComboBox(Components[i]).ListSource.DataSet.Close();
       TDBLookupComboBox(Components[i]).ListSource.DataSet.Open();
    end;
end;

procedure TfrmAbsRel.FechaLookUps;
var
  i : Integer;
begin
  for i := 0 to Self.ComponentCount -1 do
    if (Components[i] is TDBLookupComboBox ) then
      TDBLookupComboBox(Components[i]).ListSource.DataSet.Close();
end;

procedure TfrmAbsRel.FormActivate(Sender: TObject);
begin
  AtualizaLookUps();
end;

procedure TfrmAbsRel.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  FechaLookUps();
end;

end.
